﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace Studio
{
	// Token: 0x0200050B RID: 1291
	public class MapList : MonoBehaviour
	{
		// Token: 0x060020F9 RID: 8441 RVA: 0x000CB12C File Offset: 0x000C932C
		public void UpdateInfo()
		{
			if (!this.isInit)
			{
				return;
			}
			foreach (KeyValuePair<int, GameSceneNode> keyValuePair in this.dicNode)
			{
				keyValuePair.Value.select = false;
			}
			GameSceneNode gameSceneNode = null;
			if (this.dicNode.TryGetValue(Singleton<Studio>.Instance.sceneInfo.map, out gameSceneNode))
			{
				gameSceneNode.select = true;
				this.select = Singleton<Studio>.Instance.sceneInfo.map;
			}
			else if (this.dicNode.TryGetValue(-1, out gameSceneNode))
			{
				gameSceneNode.select = true;
				this.select = -1;
			}
		}

		// Token: 0x060020FA RID: 8442 RVA: 0x000CB200 File Offset: 0x000C9400
		public void OnClick(int _no)
		{
			Singleton<Studio>.Instance.AddMap(_no, true);
			GameSceneNode gameSceneNode = null;
			if (this.dicNode.TryGetValue(this.select, out gameSceneNode))
			{
				gameSceneNode.select = false;
			}
			if (this.dicNode.TryGetValue(_no, out gameSceneNode))
			{
				gameSceneNode.select = true;
			}
			this.select = _no;
		}

		// Token: 0x060020FB RID: 8443 RVA: 0x000CB25C File Offset: 0x000C945C
		private void InitList()
		{
			this.AddNode(-1, "なし");
			foreach (KeyValuePair<int, Info.LoadCommonInfo> keyValuePair in Singleton<Info>.Instance.dicMapLoadInfo)
			{
				this.AddNode(keyValuePair.Key, keyValuePair.Value.name);
			}
			GameSceneNode gameSceneNode = null;
			if (this.dicNode.TryGetValue(Singleton<Studio>.Instance.sceneInfo.map, out gameSceneNode))
			{
				gameSceneNode.select = true;
			}
			this.isInit = true;
		}

		// Token: 0x060020FC RID: 8444 RVA: 0x000CB30C File Offset: 0x000C950C
		private void AddNode(int _key, string _name)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.objectNode);
			gameObject.transform.SetParent(this.transformRoot, false);
			if (!gameObject.activeSelf)
			{
				gameObject.SetActive(true);
			}
			GameSceneNode component = gameObject.GetComponent<GameSceneNode>();
			int key = _key;
			component.AddActionToButton(delegate
			{
				this.OnClick(key);
			});
			component.text = _name;
			this.dicNode.Add(key, component);
		}

		// Token: 0x060020FD RID: 8445 RVA: 0x000CB390 File Offset: 0x000C9590
		private void Awake()
		{
			this.isInit = false;
			this.InitList();
		}

		// Token: 0x0400227B RID: 8827
		[SerializeField]
		private GameObject objectNode;

		// Token: 0x0400227C RID: 8828
		[SerializeField]
		private Transform transformRoot;

		// Token: 0x0400227D RID: 8829
		private int select = -1;

		// Token: 0x0400227E RID: 8830
		private Dictionary<int, GameSceneNode> dicNode = new Dictionary<int, GameSceneNode>();

		// Token: 0x0400227F RID: 8831
		private bool isInit;
	}
}
